<template>
	<view>
		<u-navbar
			title-color="#fff"
			back-icon-color="#fff"
			z-index="9999"
			:is-fixed="isFixed"
			:is-back="isBack"
			:background="background"
			:back-text-style="{ color: '#fff' }"
			:title="title"
			:custom-back="pageBack"
			:back-icon-name="backIconName"
		>
			<view class="navbar-right" slot="right">
				<view class="message-box right-item" @click="addTask"><u-icon name="plus" size="38" color="#fff" style="margin-right:30rpx;"></u-icon></view>
			</view>
		</u-navbar>
		<view class="u-flex u-flex-col">
		<SearchBox class="mySearchBox" :keyword="keyword"></SearchBox>
		<view class="wrap u-flex-1">
			<scroll-view scroll-y class="myScroll" @scrolltolower="reachBottom">
				<view class="page-box">
					<view class="order">
						<view class="item">
							<view class="img"><image src="https://uviewui.com/common/logo.png"></image></view>
							<view class="u-flex-1">
								<view>
									<text>任务名称</text>
									<text class="u-float-right u-font-12 u-">2018-12-15</text>
								</view>
								<view class="u-font-12">部门：器材部</view>
								<view class="u-font-12">简述：关于任务的简要说明</view>
								<view class="item_oper">
									<u-button type="primary" size="mini">流转</u-button>
									<u-button type="info" size="mini">审批</u-button>
								</view>
							</view>
						</view>
						<view class="item">
							<view class="img"><image src="https://uviewui.com/common/logo.png"></image></view>
							<view class="u-flex-1">
								<view>
									<text>任务名称</text>
									<text class="u-float-right u-font-12 u-">2018-12-15</text>
								</view>
								<view class="u-font-12">部门：器材部</view>
								<view class="u-font-12">简述：关于任务的简要说明</view>
								<view class="item_oper">
									<u-button type="warning" size="mini">延缓</u-button>
									<u-button type="info" size="mini">审批</u-button>
								</view>
							</view>
						</view>
					</view>
					<!-- <u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore> -->
				</view>
			</scroll-view>
		</view>
		</view>
	</view>
</template>

<script>
import SearchBox from '@/components/searchBox.vue';
export default {
	components: {
		SearchBox
	},
	data() {
		return {
			title: '办文办事',
			background: { backgroundColor: '#0251b6' },
			backIconName: 'nav-back',
			right: false,
			isBack: true,
			isFixed: true,
			keyword: '',
			current: 0,
			swiperCurrent: 0,
			tabsHeight: 0,
			dx: 0,
			loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore']
		};
	},
	onLoad() {
		// this.getOrderList(0);
		// this.getOrderList(1);
		// this.getOrderList(3);
	},
	computed: {
		// 价格小数
		priceDecimal() {
			return val => {
				if (val !== parseInt(val)) return val.slice(-2);
				else return '00';
			};
		},
		// 价格整数
		priceInt() {
			return val => {
				if (val !== parseInt(val)) return val.split('.')[0];
				else return val;
			};
		}
	},
	methods: {
		//页面跳转
		addTask(text) {
			this.$u.route({
				url: 'pages/workbench/mobileOffice/work/addtask'
			});
		},
		reachBottom() {
			// 此tab为空数据
			console.log('底部了');
		},
		// 页面数据
		getOrderList(idx) {
			for (let i = 0; i < 5; i++) {
				let index = this.$u.random(0, this.dataList.length - 1);
				let data = JSON.parse(JSON.stringify(this.dataList[index]));
				data.id = this.$u.guid();
				this.orderList[idx].push(data);
			}
			this.loadStatus.splice(this.current, 1, 'loadmore');
		},
		// 总价
		totalPrice(item) {
			let price = 0;
			item.map(val => {
				price += parseFloat(val.price);
			});
			return price.toFixed(2);
		},
		// 总件数
		totalNum(item) {
			let num = 0;
			item.map(val => {
				num += val.number;
			});
			return num;
		},
		// tab栏切换
		change(index) {
			this.swiperCurrent = index;
			// this.getOrderList(index);
		},
		pageBack(){
			uni.navigateBack({
				delta:1
			})
		},
	}
};
</script>

<style>
/* #ifndef H5 */
page {
	height: 100%;
	/* background-color: #f2f2f2; */
}
/* #endif */
</style>

<style lang="scss" scoped>
.u-tabs-box {
	border-bottom: 1px solid #d7d7d7;
}
.myScroll {
	height: 100%;
	width: 100%;
}
.order {
	width: 100%;
	background-color: #ffffff;
	box-sizing: border-box;
	padding-left: 30rpx;
	font-size: 28rpx;

	.item {
		display: flex;
		padding: 20rpx;
		padding-right: 30rpx;
		border-bottom: 1px solid #d7d7d7;
		.img {
			image {
				width: 100rpx;
				height: 100rpx;
				border-radius: 10rpx;
				margin-right: 30rpx;
			}
		}
		.content {
			.title {
				font-size: 28rpx;
				line-height: 50rpx;
			}
			.type {
				margin: 10rpx 0;
				font-size: 24rpx;
				color: $u-tips-color;
			}
			.delivery-time {
				color: #e5d001;
				font-size: 24rpx;
			}
		}
		.right {
			margin-left: 10rpx;
			padding-top: 20rpx;
			text-align: right;
			.decimal {
				font-size: 24rpx;
				margin-top: 4rpx;
			}
			.number {
				color: $u-tips-color;
				font-size: 24rpx;
			}
		}
		.item_oper {
			border-top: 1px solid #d9d9d9;
			padding-top: 20rpx;
			margin-top: 20rpx;
			text-align: right;
			button {
				display: inline-block;
				margin-left: 30rpx;
			}
		}
	}
	.total {
		margin-top: 20rpx;
		text-align: right;
		font-size: 24rpx;
		.total-price {
			font-size: 32rpx;
		}
	}
	.bottom {
		display: flex;
		margin-top: 40rpx;
		padding: 0 10rpx;
		justify-content: space-between;
		align-items: center;
		.btn {
			line-height: 52rpx;
			width: 160rpx;
			border-radius: 26rpx;
			border: 2rpx solid $u-border-color;
			font-size: 26rpx;
			text-align: center;
			color: $u-type-info-dark;
		}
		.evaluate {
			color: $u-type-warning-dark;
			border-color: $u-type-warning-dark;
		}
	}
}
.page-box {
	.dataOper {
		text-align: right;
		padding: 30rpx;
		button {
			display: inline-block;
		}
	}
}
.centre {
	text-align: center;
	margin: 200rpx auto;
	font-size: 32rpx;
	image {
		width: 164rpx;
		height: 164rpx;
		border-radius: 50%;
		margin-bottom: 20rpx;
	}
	.tips {
		font-size: 24rpx;
		color: #999999;
		margin-top: 20rpx;
	}
	.btn {
		margin: 80rpx auto;
		width: 200rpx;
		border-radius: 32rpx;
		line-height: 64rpx;
		color: #ffffff;
		font-size: 26rpx;
		background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
	}
}
.wrap {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
}
.swiper-box {
	flex: 1;
}
.swiper-item {
	height: 100%;
}
</style>
